
<!--{template admin/header}-->
<style type="text/css">
    .upimg_img{
        width:15%;
        padding: 5px;
        display: inline-block;
        text-align: center;
    }
    .upimg_img img{
        width:100%;
        margin: 8px 0;
    }
    a.u-del {
        color: #fff;
    }
    .u-del {
        background: #ddd;
        width: 15px;
        height: 15px;
        color: #fff;
        text-align: center;
        line-height: 15px;
        display: inline-block;
    }
    .input-group-addon {
        padding: 6px 12px;
        font-size: 14px;
        font-weight: normal;
        line-height: 1;
        text-align: center;
        background-color: #eeeeee;
        border: 1px solid #cccccc;
        border-radius: 4px;
    }
</style>
<script src="static/js/date/WdatePicker.js" type="text/javascript"></script>
<script type="text/javascript">
    function checkinput() {

        if (document.getElementById('goodsname').value == '') {
            MessageBox('notice', "请输入商品名字", '提示');
            return false;
        }
        if (Number(document.getElementById('goodsnum').value) == 0) {
            MessageBox('notice', "请输入商品总数", '提示');
            return false;
        }
        var goos_style = $("#goos_style").val();
        if(goos_style == 'entity'){
            if (document.getElementById('product_bn').value == '') {
                MessageBox('notice', "请输入货号", '提示');
                return false;
            }
            if (document.getElementById('barcode').value == '') {
                MessageBox('notice', "请输入条形码", '提示');
                return false;
            }
        }
        
    }
    function style_change(){
        var goos_style = $("#goos_style").val();
        if(goos_style == 'entity'){
            $(".entity").show();
            $(".img_size").html("大小：640*562");
        }else if(goos_style == 'fictitious'){
            $(".entity").hide();
            $(".img_size").html("大小：400*400");
        }
    }
    function property(){
        $(".property").click(function() {
            $(this).contenteditable = "true";
            $(this).css('min-width', '100%');
            //html = $(this).html();
        });
        $(".property").blur(function() {
            $(this).contenteditable = "true";
            var content = $(this).html();
            if (content == '') {
                //$(this).html(html);
                $(this).parent().find(".property-input").val('');
            } else {
                $(this).parent().find(".property-input").val(content);
            }
        });
    }
    function specify(){
        $(".specify").click(function() {
            $(this).contenteditable = "true";
            $(this).css('min-width', '100%');
            //html = $(this).html();
        });
        $(".specify").blur(function() {
            $(this).contenteditable = "true";
            var content = $(this).html();
            if (content == '') {
                $(this).parent().find(".specify-input").val('');
            } else {
                $(this).parent().find(".specify-input").val(content);
            }
        });
    }
    $(function(){
        style_change();
        property();
        specify();
        $("#goos_style").change(function(){
            style_change();
        });
        $(".add-property").click(function() {
            var property_html = '';
            property_html += '<tr>';
            property_html += '<td class="altbg1" width="15%" bgcolor="#F8F8F8"><span class="input-group-addon property" contenteditable=true>请点击输入属性名称</span><input class="property-input" type="hidden" name="property_key[]" /></td>';
            property_html += '<td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF"><input type="text" class="form-control" placeholder="请输入属性值" name="property_val[]" /></td>';
            property_html += '</tr>';
            $(".property-box").before(property_html);
            property();
        });
        $(".add-specify").click(function() {
            var specify_html = '';
            specify_html += '<tr>';
            specify_html += '<td class="altbg1" width="15%" bgcolor="#F8F8F8"><span class="input-group-addon specify" contenteditable=true>请点击输入参数名称</span><input class="specify-input" type="hidden" name="specify_key[]" /></td>';
            specify_html += '<td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF"><input type="text" class="form-control" placeholder="请输入属性值" name="specify_val[]" /></td>';
            specify_html += '</tr>';
            $(".specifications").before(specify_html);
            specify();
        });
    })
</script>
<script type="text/javascript" charset="utf-8" src="static/js/kind/kindeditor.js"></script>
<script type="text/javascript">
    KE.show({
        id: 'content'
    });
</script>
<script type="text/javascript" src="static/js/imgupload.js"></script>
<script type="text/javascript">
    $(function(){
        $('#publisher_file').uploadify({
            'uploader':'{conf site_url}/images/uploadify/uploadify.swf?id=&random=' + Math.random(), 
            'script':'{echo urlencode({conf site_url}."/ajax.php?mod=uploadify&code=uploadimg")}', 
            'cancelImg':'{conf site_url}/images/uploadify/cancel.png', 
            'buttonImg':'{conf site_url}/images/uploadify/upload.gif', 
            'width':52, 
            'height':52, 
            'multi':true, 
            'auto':true, 
            'sizeLimit':'{conf image_size_limit}', 
            'fileExt':'*.jpg;*.png;*.gif;*.jpeg', 
            'fileDesc':'请选择图片文件(*.jpg;*.png;*.gif;*.jpeg)', 
            'queueID':'uploadifyQueueDiv', 
            'wmode':'transparent', 
            'fileDataName':'image', 
            'queueSizeLimit':'5', 
            'simUploadLimit':1, 
            'scriptData':{'cookie_auth':'{echo urlencode(jsg_getcookie("auth"))}'}, 
            'onSelect':function(event, ID, fileObj){}, 
            'onSelectOnce':function(event, data){ }, 
            'onProgress':function(event, ID, fileObj, data){return false; }, 
            'onComplete':function(event, ID, fileObj, response, data){
                eval('var r =' + response + ';'); 
                if (r.done){
                    var rv = r.retval; 
                    if (rv.id > 0 && rv.src.length > 0) {
                        var idval = ('undefined' == typeof (rv.id) ? 0 : rv.id);
                        var srcval = ('undefined' == typeof (rv.src) ? 0 : rv.src);
                        var imageIdsCount = 0;
                        $(".upimg_img").each(function() {
                            imageIdsCount += 1;
                        });
                        if (imageIdsCount >= 5) {
                            MessageBox('warning', '本次图片数量超过限制了');
                            return false;
                        }
                        $('#viewImgDiv').append("<div class='upimg_img' id='upimg_" + idval + "'><input type='hidden' name='topic[]' value='" + idval + "' /><input type='hidden' name='files[]' value='" + srcval + "' /><img src='" + srcval + "'/><a href='javascript:void(0);' onclick='imageUploadifyDelete(" + idval + "); return false;' title='删除图片' class='u-del'>X</a></div>");
                        //imageUploadifyComplete('{$h_key}', rv.id, rv.src, fileObj.name); 
                    }
                }
            }, 
            
        }); 
    });
</script>
<form method="post" action="admin.php?mod=mall&code=do_modify_goods" enctype="multipart/form-data" onsubmit="return checkinput()">
    <table cellspacing="1" cellpadding="4" width="100%" align="center" class="tableborder">
        <tr class="header">
            <td colspan="2">商品编辑</td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">商品名称</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input id="goodsname" type="text" name="data[name]" value="{$info['name']}"  style="width:600px;" maxlength="100">（不超过100个字符）
            </td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">副标题</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="text" name="data[subtitle]" value="{$info['subtitle']}" style="width:600px;" maxlength="100">（不超过100个字符）
            </td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">商品类型</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <select name="data[style]" id="goos_style">
                    <option value="entity" <!--{if isset($info['style']) && $info['style'] == 'entity'}--> selected="selected"<!--{/if}-->>实体物品</option>
                    <option value="fictitious"<!--{if isset($info['style']) && $info['style'] == 'fictitious'}--> selected="selected"<!--{/if}-->>虚拟物品</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">商品SN号</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="text" name="data[sn]" value="{$info['sn']}">（自己对商品定义的编号，可以不填写）
            </td>
        </tr>
        <tr class="entity">
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">货号</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="text" name="data[product_bn]" id="product_bn" value="{$info['product_bn']}">（必填）
            </td>
        </tr>
        <tr class="entity">
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">条形码</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="text" name="data[barcode]" id="barcode" value="{$info['barcode']}">（必填）
            </td>
        </tr>
        <tr class="entity">
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">重量</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="text" name="data[weight]" value="{$info['weight']}">
            </td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">产地</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="text" name="data[producer]" value="{$info['producer']}">
            </td>
        </tr>
        <tr class="entity">
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">所需金额</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="text" name="data[price]" value="{$info['price']}" >（即：购买该商品所需要的金额）
            </td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">所需{$config['credits_name']}</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="text" name="data[gold]" value="{$info['gold']}" >（即：兑换该商品所需要的{$config['credits_name']}）
                <input type="hidden" name="data[credit]" value="{$info['credit']}">
            </td>
        </tr>
<!--        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">总积分要求</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="text" name="data[credit]" value="{$info['credit']}">（即：兑换门槛，总积分必须大于或等于该设置分的才可以兑换，0为不做要求，无兑换门槛。）
            </td>
        </tr>-->
        <!--{loop $propertys $k $v}-->
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8"><span class="input-group-addon property" contenteditable=true>{$v['key']}</span><input class="property-input" type="hidden" name="property_key[]" value="{$v['key']}" /></td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF"><input type="text" class="form-control" placeholder="请输入属性值" name="property_val[]" value="{$v['val']}" /></td>
        </tr>
        <!--{/loop}-->
        <tr class="property-box">
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">添加下单勾选属性（分类）</td>
            <td class="altbg2" width="85%" bgcolor="#FFFFFF"><span class="button add-property">添加</span>（如口味：原味,杏仁,小麦,奶油。注：多种请以小写的逗号（,）隔开）</td>
        </tr>
        <!--{loop $specifys $k $v}-->
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8"><span class="input-group-addon specify" contenteditable=true>{$v['key']}</span><input class="specify-input" type="hidden" name="specify_key[]" value="{$v['key']}" /></td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF"><input type="text" class="form-control" placeholder="请输入属性值" name="specify_val[]" value="{$v['val']}" /></td>
        </tr>
        <!--{/loop}-->
        <tr class="specifications">
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">添加规格参数</td>
            <td class="altbg2" width="85%" bgcolor="#FFFFFF"><span class="button add-specify">添加</span></td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">商品详情</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <textarea name="data[desc]" style="width:600px;height:300px;" id="content">{$info['desc']}</textarea>
            </td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">售后保障</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <textarea name="data[after_sale]" style="width:600px;height:300px;">{$info['after_sale']}</textarea>
            </td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">商品图片</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <!--{if $info['image']}--><img src="{$info['image']}" width="300" height="300"><br><!--{/if}-->
                <input type="file" name="image" >（<span class="img_size">大小：640*352</span>）
            </td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">商品轮播图片</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="file" name="images" id="publisher_file" >（<span class="img_size">大小：640*352</span>，最多只能添加5张）
                <div id="viewImgDiv">
                    <!--{loop $images $k $v}-->
                    <div class="upimg_img" id="upimg_{$v['tid']}">
                        <input type="hidden" name="topic[]" value="{$v['tid']}" />
                        <input type="hidden" name="files[]" value="{$v['img']}" />
                        <img src="{$v['img']}" />
                        <a href="javascript:void(0);" onclick="imageUploadifyDelete({$v['tid']}); return false;" title="删除图片" class="u-del">X</a></div>
                    <!--{/loop}-->
                </div>
            </td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">总商品数（库存数）</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input id="goodsnum" type="text" name="data[total]" value="{$info['total']}">（即：库存数，必须有值）
            </td>
        </tr>
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">商品有效期</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <!--{if $info['expire'] == '0'}-->
                <input type="text" id="starttime" name="data[expire]" value="">（即：在该时间之前可以兑换，超过该时间后不可兑换，自动下架。）
                <!--{else}-->
                <input type="text" id="starttime" name="data[expire]" value="{eval echo date("Y-m-d H:i",$info['expire']);}" onClick="WdatePicker({dateFmt:'yyyy-MM-dd  HH:mm'});">（即：在该时间之前可以兑换，超过该时间后不可兑换，自动下架。）
                <!--{/if}-->
                
            </td>
        </tr>	
        <tr>
            <td class="altbg1" width="15%" bgcolor="#F8F8F8">商品排序</td>
            <td class="altbg2" width="85%" align="right" bgcolor="#FFFFFF">
                <input type="text" name="data[order]" value="{$info['order']}">（由大到小排序）
            </td>
        </tr>

    </table>
    <br><input type="hidden" name="id" value="{$info['id']}">
    <center><input type="submit" class="button" id="submit" name="addsubmit" value="保 存"><a href="javascript:history.go(-1)" class="button" id="submit" name="addsubmit">返回</a></center>
</form>